home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / glibc-1.09 / glibc-1 / glibc-1.09.1 / sysdeps / mach / hurd / __fork.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-04  |  19.5 KB  |  567 lines

  1. /* Copyright (C) 1994 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3.  
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8.  
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. Library General Public License for more details.
  13.  
  14. You should have received a copy of the GNU Library General Public
  15. License along with the GNU C Library; see the file COPYING.LIB.  If
  16. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  17. Cambridge, MA 02139, USA.  */
  18.  
  19. #include <errno.h>
  20. #include <unistd.h>
  21. #include <hurd.h>
  22. #include <hurd/signal.h>
  23. #include <setjmp.h>
  24. #include "thread_state.h"
  25. #include <sysdep.h>        /* For stack growth direction.  */
  26. #include "set-hooks.h"
  27. #include <assert.h>
  28. #include "hurdmalloc.h"        /* XXX */
  29.  
  30. extern void _hurd_longjmp_thread_state (struct machine_thread_state *,
  31.                     jmp_buf env, int value);
  32.  
  33.  
  34. /* Things that want to be locked while forking.  */
  35. struct
  36.   {
  37.     size_t n;
  38.     struct mutex *locks[0];
  39.   } _hurd_fork_locks;
  40.  
  41.  
  42. /* Things that want to be called before we fork, to prepare the parent for
  43.    task_create, when the new child task will inherit our address space.  */
  44. DEFINE_HOOK (_hurd_fork_prepare_hook, (void));
  45.  
  46. /* Things that want to be called when we are forking, with the above all
  47.    locked.  They are passed the task port of the child.  The child process
  48.    is all set up except for doing proc_child, and has no threads yet.  */
  49. DEFINE_HOOK (_hurd_fork_setup_hook, (void));
  50.  
  51. /* Things to be run in the child fork.  */
  52. DEFINE_HOOK (_hurd_fork_child_hook, (void));
  53.  
  54. /* Things to be run in the parent fork.  */
  55. DEFINE_HOOK (_hurd_fork_parent_hook, (void));
  56.  
  57.  
  58. /* Clone the calling process, creating an exact copy.
  59.    Return -1 for errors, 0 to the new process,
  60.    and the process ID of the new process to the old process.  */
  61. pid_t
  62. __fork (void)
  63. {
  64.   jmp_buf env;
  65.   pid_t pid;
  66.   size_t i;
  67.   error_t err;
  68.   thread_t thread_self = __mach_thread_self ();
  69.   struct hurd_sigstate *volatile ss;
  70.  
  71.   void unlockss (void)
  72.     {
  73.       ss->critical_section = 0;
  74.       /* XXX Copying mutex into child and calling mutex_unlock lossy.  */
  75.       __mutex_unlock (&ss->lock);
  76.       __mutex_unlock (&_hurd_siglock);
  77.       ss = NULL;        /* Make sure we crash if we use it again.  */
  78.     }
  79.  
  80.   ss = _hurd_self_sigstate ();
  81.   ss->critical_section = 1;
  82.   __mutex_lock (&_hurd_siglock);
  83.  
  84.   if (! setjmp (env))
  85.     {
  86.       process_t newproc;
  87.       task_t newtask;
  88.       thread_t thread, sigthread;
  89.       mach_port_urefs_t thread_refs, sigthread_refs;
  90.       struct machine_thread_state state;
  91.       unsigned int statecount;
  92.       mach_port_t *portnames = NULL;
  93.       unsigned int nportnames = 0;
  94.       mach_port_type_t *porttypes = NULL;
  95.       unsigned int nporttypes = 0;
  96.       thread_t *threads = NULL;
  97.       unsigned int nthreads = 0;
  98.       int ports_locked = 0;
  99.  
  100.       /* Run things that prepare for forking before we create the task.  */
  101.       RUN_HOOK (_hurd_fork_prepare_hook, ());
  102.  
  103.       /* Lock things that want to be locked before we fork.  */
  104.       for (i = 0; i < _hurd_fork_locks.n; ++i)
  105.     __mutex_lock (_hurd_fork_locks.locks[i]);
  106.       
  107.       newtask = MACH_PORT_NULL;
  108.       thread = sigthread = MACH_PORT_NULL;
  109.       newproc = MACH_PORT_NULL;
  110.  
  111.       /* Lock all the port cells for the standard ports while we copy the
  112.      address space.  We want to insert all the send rights into the
  113.      child with the same names.  */
  114.       for (i = 0; i < _hurd_nports; ++i)
  115.     __spin_lock (&_hurd_ports[i].lock);
  116.       ports_locked = 1;
  117.  
  118.       /* Create the child task.  It will inherit a copy of our memory.  */
  119.       if (err = __task_create (__mach_task_self (), 1, &newtask))
  120.     goto lose;
  121.  
  122.       /* Fetch the names of all ports used in this task.  */
  123.       if (err = __mach_port_names (__mach_task_self (),
  124.                    &portnames, &nportnames,
  125.                    &porttypes, &nporttypes))
  126.     goto lose;
  127.       if (nportnames != nporttypes)
  128.     {
  129.       err = EGRATUITOUS;
  130.       goto lose;
  131.     }
  132.  
  133.       /* Get send rights for all the threads in this task.
  134.      We want to avoid giving these rights to the child.  */
  135.       if (err = __task_threads (__mach_task_self (), &threads, &nthreads))
  136.     goto lose;
  137.  
  138.       /* Get the child process's proc server port.  We will insert it into
  139.      the child with the same name as we use for our own proc server
  140.      port; and we will need it to set the child's message port.  */
  141.       if (err = __proc_task2proc (_hurd_ports[INIT_PORT_PROC].port,
  142.                   newtask, &newproc))
  143.     goto lose;
  144.  
  145.       /* Insert all our port rights into the child task.  */
  146.       thread_refs = sigthread_refs = 0;
  147.       for (i = 0; i < nportnames; ++i)
  148.     {
  149.       if (porttypes[i] & MACH_PORT_TYPE_RECEIVE)
  150.         {
  151.           /* This is a receive right.  We want to give the child task
  152.          its own new receive right under the same name.  */
  153.           err = __mach_port_allocate_name (newtask,
  154.                            MACH_PORT_RIGHT_RECEIVE,
  155.                            portnames[i]);
  156.           if (err == KERN_NAME_EXISTS)
  157.         {
  158.           /* It already has a right under this name (?!).  Well,
  159.              there is this bizarre old Mach IPC feature (in #ifdef
  160.              MACH_IPC_COMPAT in the ukernel) which results in new
  161.              tasks getting a new receive right for task special
  162.              port number 2.  What else might be going on I'm not
  163.              sure.  So let's check.  */
  164. #if !MACH_IPC_COMPAT
  165. #define TASK_NOTIFY_PORT 2
  166. #endif
  167.           assert (({ mach_port_t thisport, notify_port;
  168.                  mach_msg_type_name_t poly;
  169.                  (__task_get_special_port (newtask,
  170.                                TASK_NOTIFY_PORT,
  171.                                ¬ify_port) == 0 &&
  172.                   __mach_port_extract_right 
  173.                   (newtask,
  174.                    portnames[i],
  175.                    MACH_MSG_TYPE_MAKE_SEND,
  176.                    &thisport, &poly) == 0 &&
  177.                   (thisport == notify_port) &&
  178.                   __mach_port_deallocate (__mach_task_self (),
  179.                               thisport) == 0 &&
  180.                   __mach_port_deallocate (__mach_task_self (),
  181.                               notify_port) == 0);
  182.                }));
  183.         }
  184.           else if (err)
  185.         goto lose;
  186.           if (porttypes[i] & MACH_PORT_TYPE_SEND)
  187.         {
  188.           /* Give the child as many send rights for its receive
  189.              right as we have for ours.  */
  190.           mach_port_urefs_t refs;
  191.           mach_port_t port;
  192.           mach_msg_type_name_t poly;
  193.           if (err = __mach_port_get_refs (__mach_task_self (),
  194.                           portnames[i],
  195.                           MACH_PORT_RIGHT_SEND,
  196.                           &refs))
  197.             goto lose;
  198.           if (err = __mach_port_extract_right (newtask,
  199.                                portnames[i],
  200.                                MACH_MSG_TYPE_MAKE_SEND,
  201.                                &port, &poly))
  202.             goto lose;
  203.           if (portnames[i] == _hurd_msgport)
  204.             {
  205.               /* We just created a receive right for the child's
  206.              message port and are about to insert send rights
  207.              for it.  Now, while we happen to have a send right
  208.              for it, give it to the proc server.  */
  209.               mach_port_t old;
  210.               if (err = __proc_setmsgport (newproc, port, &old))
  211.             goto lose;
  212.               if (old != MACH_PORT_NULL)
  213.             /* XXX what to do here? */
  214.             __mach_port_deallocate (__mach_task_self (), old);
  215.             }
  216.           if (err = __mach_port_insert_right (newtask,
  217.                               portnames[i],
  218.                               port,
  219.                               MACH_MSG_TYPE_MOVE_SEND))
  220.             goto lose;
  221.           if (refs > 1 &&
  222.               (err = __mach_port_mod_refs (newtask,
  223.                            portnames[i],
  224.                            MACH_PORT_RIGHT_SEND,
  225.                            refs - 1)))
  226.             goto lose;
  227.         }
  228.           if (porttypes[i] & MACH_PORT_TYPE_SEND_ONCE)
  229.         {
  230.           /* Give the child a send-once right for its receive right,
  231.              since we have one for ours.  */
  232.           mach_port_t port;
  233.           mach_msg_type_name_t poly;
  234.           if (err = __mach_port_extract_right
  235.               (newtask,
  236.                portnames[i],
  237.                MACH_MSG_TYPE_MAKE_SEND_ONCE,
  238.                &port, &poly))
  239.             goto lose;
  240.           if (err = __mach_port_insert_right
  241.               (newtask,
  242.                portnames[i], port,
  243.                MACH_MSG_TYPE_MOVE_SEND_ONCE))
  244.             goto lose;
  245.         }
  246.         }
  247.       else if (porttypes[i] & MACH_PORT_TYPE_SEND)
  248.         {
  249.           /* This is a send right or a dead name.
  250.          Give the child as many references for it as we have.  */
  251.           mach_port_urefs_t refs, *record_refs = NULL;
  252.           mach_port_t insert;
  253.           if (portnames[i] == newtask)
  254.         /* Skip the name we use for the child's task port.  */
  255.         continue;
  256.           if (portnames[i] == __mach_task_self ())
  257.         /* For the name we use for our own task port,
  258.            insert the child's task port instead.  */
  259.         insert = newtask;
  260.           else if (portnames[i] == _hurd_ports[INIT_PORT_PROC].port)
  261.         {
  262.           /* Get the proc server port for the new task.  */
  263.           if (err = __proc_task2proc (portnames[i], newtask, &insert))
  264.             goto lose;
  265.         }
  266.           else if (portnames[i] == thread_self)
  267.         {
  268.           /* For the name we use for our own thread port, we will
  269.              insert the thread port for the child main user thread
  270.              after we create it.  */
  271.           insert = MACH_PORT_NULL;
  272.           record_refs = &thread_refs;
  273.           /* Allocate a dead name right for this name as a
  274.                      placeholder, so the kernel will not chose this name
  275.                      for any other new port (it might use it for one of the
  276.                      rights created when a thread is created).  */
  277.           if (err = __mach_port_allocate_name
  278.               (newtask, MACH_PORT_RIGHT_DEAD_NAME, portnames[i]))
  279.             goto lose;
  280.         }
  281.           else if (portnames[i] == _hurd_msgport_thread)
  282.         /* For the name we use for our signal thread's thread port,
  283.            we will insert the thread port for the child's signal
  284.            thread after we create it.  */
  285.         {
  286.           insert = MACH_PORT_NULL;
  287.           record_refs = &sigthread_refs;
  288.           /* Allocate a dead name right as a placeholder.  */
  289.           if (err = __mach_port_allocate_name
  290.               (newtask, MACH_PORT_RIGHT_DEAD_NAME, portnames[i]))
  291.             goto lose;
  292.         }
  293.           else
  294.         {
  295.           /* Skip the name we use for any of our own thread ports.  */
  296.           unsigned int j;
  297.           for (j = 0; j < nthreads; ++j)
  298.             if (portnames[i] == threads[j])
  299.               break;
  300.           if (j < nthreads)
  301.             continue;
  302.  
  303.           insert = portnames[i];
  304.         }
  305.           /* Find out how many user references we have for
  306.          the send right with this name.  */
  307.           if (err = __mach_port_get_refs (__mach_task_self (),
  308.                           portnames[i],
  309.                           MACH_PORT_RIGHT_SEND,
  310.                           record_refs ?: &refs))
  311.         goto lose;
  312.           if (insert == MACH_PORT_NULL)
  313.         continue;
  314.           /* Insert the chosen send right into the child.  */
  315.           err = __mach_port_insert_right (newtask,
  316.                           portnames[i],
  317.                           insert,
  318.                           MACH_MSG_TYPE_COPY_SEND);
  319.           if (err == KERN_NAME_EXISTS)
  320.         {
  321.           /* It already has a send right under this name (?!).
  322.              Well, it starts out with a send right for its task
  323.              port, and inherits the bootstrap and exception ports
  324.              from us.  */
  325.           mach_port_t childport;
  326.           mach_msg_type_name_t poly;
  327.           assert (__mach_port_extract_right (newtask, portnames[i],
  328.                              MACH_MSG_TYPE_COPY_SEND,
  329.                              &childport, &poly) == 0 &&
  330.               childport == insert &&
  331.               __mach_port_deallocate (__mach_task_self (),
  332.                           childport) == 0);
  333.         }
  334.           else if (err)
  335.         goto lose;
  336.           /* Give the child as many user references as we have.  */
  337.           if (refs > 1 &&
  338.           (err = __mach_port_mod_refs (newtask,
  339.                            portnames[i],
  340.                            MACH_PORT_RIGHT_SEND,
  341.                            refs - 1)))
  342.         goto lose;
  343.         }
  344.     }
  345.  
  346.       /* Unlock the standard port cells.  The child must unlock its own
  347.      copies too.  */
  348.       for (i = 0; i < _hurd_nports; ++i)
  349.     __spin_unlock (&_hurd_ports[i].lock);
  350.       ports_locked = 0;
  351.  
  352.       /* Unlock the signal state.  The child must unlock its own copy too.  */
  353.       unlockss ();
  354.  
  355.       /* Create the child main user thread and signal thread.  */
  356.       if ((err = __thread_create (newtask, &thread)) ||
  357.       (err = __thread_create (newtask, &sigthread)))
  358.     goto lose;
  359.  
  360.       /* Insert send rights for those threads.  We previously allocated
  361.          dead name rights with the names we want to give the thread ports
  362.          in the child as placeholders.  Now deallocate them so we can use
  363.          the names.  */
  364.       if ((err = __mach_port_deallocate (newtask, thread_self)) ||
  365.       (err = __mach_port_insert_right (newtask, thread_self,
  366.                        thread, MACH_MSG_TYPE_COPY_SEND)))
  367.     goto lose;
  368.       /* We have one extra user reference created at the beginning of this
  369.      function, accounted for by mach_port_names (and which will thus be
  370.      accounted for in the child below).  This extra right gets consumed
  371.      in the child by the store into _hurd_sigthread in the child fork.  */
  372.       if (thread_refs > 1 &&
  373.       (err = __mach_port_mod_refs (newtask, thread_self,
  374.                        MACH_PORT_RIGHT_SEND,
  375.                        thread_refs - 1)))
  376.     goto lose;
  377.       if ((_hurd_msgport_thread != MACH_PORT_NULL) /* Let user have none.  */
  378.       && ((err = __mach_port_deallocate (newtask, _hurd_msgport_thread)) ||
  379.           (err = __mach_port_insert_right (newtask, _hurd_msgport_thread,
  380.                            sigthread,
  381.                            MACH_MSG_TYPE_COPY_SEND))))
  382.     goto lose;
  383.       if (sigthread_refs > 1 &&
  384.       (err = __mach_port_mod_refs (newtask, _hurd_msgport_thread,
  385.                        MACH_PORT_RIGHT_SEND,
  386.                        sigthread_refs - 1)))
  387.     goto lose;
  388.  
  389.       /* This seems like a convenient juncture to copy the proc server's
  390.      idea of what addresses our argv and envp are found at from the
  391.      parent into the child.  Since we happen to know that the child
  392.      shares our memory image, it is we who should do this copying.  */
  393.       {
  394.     vm_address_t argv, envp;
  395.     err = (__USEPORT (PROC, __proc_get_arg_locations (port, &argv, &envp))
  396.            ?: __proc_set_arg_locations (newproc, argv, envp));
  397.     if (err)
  398.       goto lose;
  399.       }
  400.         
  401.       /* Set the child signal thread up to run the msgport server function
  402.      using the same signal thread stack copied from our address space.
  403.      We fetch the state before longjmp'ing it so that miscellaneous
  404.      registers not affected by longjmp (such as i386 segment registers)
  405.      are in their normal default state.  */
  406.       statecount = MACHINE_THREAD_STATE_COUNT;
  407.       if (err = __thread_get_state (sigthread, MACHINE_THREAD_STATE_FLAVOR,
  408.                     (int *) &state, &statecount))
  409.     goto lose;
  410. #if STACK_GROWTH_UP
  411.       state.SP = __hurd_sigthread_stack_base;
  412. #else
  413.       state.SP = __hurd_sigthread_stack_end;
  414. #endif      
  415.       MACHINE_THREAD_STATE_SET_PC (&state,
  416.                    (unsigned long int) _hurd_msgport_receive);
  417.       if (err = __thread_set_state (sigthread, MACHINE_THREAD_STATE_FLAVOR,
  418.                     (int *) &state, statecount))
  419.     goto lose;
  420.       /* We do not thread_resume SIGTHREAD here because the child
  421.      fork needs to do more setup before it can take signals.  */
  422.  
  423.       /* Set the child user thread up to return 1 from the setjmp above.  */
  424.       if (err = __thread_get_state (thread, MACHINE_THREAD_STATE_FLAVOR,
  425.                     (int *) &state, &statecount))
  426.     goto lose;
  427.       _hurd_longjmp_thread_state (&state, env, 1);
  428.       if (err = __thread_set_state (thread, MACHINE_THREAD_STATE_FLAVOR,
  429.                     (int *) &state, statecount))
  430.     goto lose;
  431.  
  432.       /* Get the PID of the child from the proc server.  We must do this
  433.      before calling proc_child below, because at that point any
  434.      authorized POSIX.1 process may kill the child task with SIGKILL.  */
  435.       if (err = __USEPORT (PROC, __proc_task2pid (port, newtask, &pid)))
  436.     goto lose;
  437.  
  438.       /* Register the child with the proc server.  It is important that
  439.      this be that last thing we do before starting the child thread
  440.      running.  Once proc_child has been done for the task, it appears
  441.      as a POSIX.1 process.  Any errors we get must be detected before
  442.      this point, and the child must have a message port so it responds
  443.      to POSIX.1 signals.  */
  444.       if (err = __USEPORT (PROC, __proc_child (port, newtask)))
  445.     goto lose;
  446.  
  447.       /* This must be the absolutely last thing we do; we can't assume that
  448.      the child will remain alive for even a moment once we do this.  We
  449.      ignore errors because we have committed to the fork and are not
  450.      allowed to return them after the process becomes visible to
  451.      POSIX.1 (which happened right above when we called proc_child).  */
  452.       (void) __thread_resume (thread);
  453.  
  454.     lose:
  455.       if (ports_locked)
  456.     for (i = 0; i < _hurd_nports; ++i)
  457.       __spin_unlock (&_hurd_ports[i].lock);
  458.  
  459.       if (newtask != MACH_PORT_NULL)
  460.     {
  461.       if (err)
  462.         __task_terminate (newtask);
  463.       __mach_port_deallocate (__mach_task_self (), newtask);
  464.     }
  465.       if (thread != MACH_PORT_NULL)
  466.     __mach_port_deallocate (__mach_task_self (), thread);
  467.       if (sigthread != MACH_PORT_NULL)
  468.     __mach_port_deallocate (__mach_task_self (), sigthread);
  469.       if (newproc != MACH_PORT_NULL)
  470.     __mach_port_deallocate (__mach_task_self (), newproc);
  471.       if (thread_self != MACH_PORT_NULL)
  472.     __mach_port_deallocate (__mach_task_self (), thread_self);
  473.  
  474.       if (portnames)
  475.     __vm_deallocate (__mach_task_self (),
  476.              (vm_address_t) portnames,
  477.              nportnames * sizeof (*portnames));
  478.       if (porttypes)
  479.     __vm_deallocate (__mach_task_self (),
  480.              (vm_address_t) porttypes,
  481.              nporttypes * sizeof (*porttypes));
  482.       if (threads)
  483.     {
  484.       for (i = 0; i < nthreads; ++i)
  485.         __mach_port_deallocate (__mach_task_self (), threads[i]);
  486.       __vm_deallocate (__mach_task_self (),
  487.                (vm_address_t) threads,
  488.                nthreads * sizeof (*threads));
  489.     }
  490.  
  491.       /* Run things that want to run in the parent to restore it to
  492.      normality.  Usually prepare hooks and parent hooks are
  493.      symmetrical: the prepare hook arrests state in some way for the
  494.      fork, and the parent hook restores the state for the parent to
  495.      continue executing normally.  */
  496.       RUN_HOOK (_hurd_fork_parent_hook, ());
  497.     }
  498.   else
  499.     {
  500.       struct hurd_sigstate *oldstates;
  501.  
  502.       /* We are the child task.  Unlock the standard port cells, which were
  503.          locked in the parent when we copied its memory.  The parent has
  504.          inserted send rights with the names that were in the cells then.  */
  505.       for (i = 0; i < _hurd_nports; ++i)
  506.     __spin_unlock (&_hurd_ports[i].lock);
  507.  
  508.       /* We are the only thread in this new task, so we will
  509.      take the task-global signals.  */
  510.       _hurd_sigthread = thread_self;
  511.  
  512.       /* Unchain the sigstate structures for threads that existed in the
  513.      parent task but don't exist in this task (the child process).
  514.      Delay freeing them until later because some of the further setup
  515.      and unlocking might be required for free to work.  */
  516.       oldstates = _hurd_sigstates;
  517.       if (oldstates == ss)
  518.     oldstates = ss->next;
  519.       else
  520.     {
  521.       while (_hurd_sigstates->next != ss)
  522.         _hurd_sigstates = _hurd_sigstates->next;
  523.       _hurd_sigstates->next = ss->next;
  524.     }
  525.       ss->next = NULL;
  526.       _hurd_sigstates = ss;
  527.  
  528.       /* Unlock our copies of the signal state locks.  */
  529.       unlockss ();
  530.  
  531.       /* Fetch our new process IDs from the proc server.  No need to
  532.      refetch our pgrp; it is always inherited from the parent (so
  533.      _hurd_pgrp is already correct), and the proc server will send us a
  534.      proc_newids notification when it changes.  */
  535.       err = __USEPORT (PROC, __proc_getpids (port, &_hurd_pid, &_hurd_ppid,
  536.                          &_hurd_orphaned));
  537.  
  538.       /* Run things that want to run in the child task to set up.  */
  539.       RUN_HOOK (_hurd_fork_child_hook, ());
  540.  
  541.       /* Set up proc server-assisted fault recovery for the signal thread.  */
  542.       _hurdsig_fault_init ();
  543.  
  544.       /* Start the signal thread listening on the message port.  */
  545.       if (!err)
  546.     err = __thread_resume (_hurd_msgport_thread);
  547.  
  548.       /* Free the old sigstate structures.  */
  549.       while (oldstates != NULL)
  550.     {
  551.       struct hurd_sigstate *next = oldstates->next;
  552.       free (oldstates);
  553.       oldstates = next;
  554.     }
  555.       /* XXX what to do if we have any errors here? */
  556.  
  557.       pid = 0;
  558.     }
  559.  
  560.   /* Unlock things we locked before creating the child task.
  561.      They are locked in both the parent and child tasks.  */
  562.   for (i = 0; i < _hurd_fork_locks.n; ++i)
  563.     __mutex_unlock (_hurd_fork_locks.locks[i]);
  564.  
  565.   return err ? __hurd_fail (err) : pid;
  566. }
  567.